home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ABUSESRC.ZIP / AbuseSrc / macabuse / imlib / port / x11 / mouse.c < prev    next >
C/C++ Source or Header  |  1997-05-20  |  2KB  |  105 lines

  1. #include "video.hpp"
  2. #include "sprite.hpp"
  3. #include "image.hpp"
  4. #include "filter.hpp"
  5. #include "mdlread.hpp"
  6. #include "monoprnt.hpp"
  7. #include "mouse.hpp"
  8. #include "xinclude.h"
  9.  
  10. extern Window root,mainwin;
  11. extern Display *display;
  12. extern int screen_num;
  13. extern Colormap XCMap;
  14. extern Screen *screen_ptr;
  15. extern unsigned border_width,depth;
  16. extern GC gc;
  17. extern XFontStruct *font_info;
  18. extern XImage *XImg;
  19.  
  20.  
  21.  
  22.  
  23.  
  24. unsigned char def_mouse[]=
  25.     { 0,2,0,0,0,0,0,0,
  26.       2,1,2,0,0,0,0,0,
  27.       2,1,1,2,0,0,0,0,
  28.       2,1,1,1,2,0,0,0,
  29.       2,1,1,1,1,2,0,0,
  30.       2,1,1,1,1,1,2,0,
  31.       0,2,1,1,2,2,0,0,
  32.       0,0,2,1,1,2,0,0,
  33.       0,0,2,1,1,2,0,0,
  34.       0,0,0,2,2,0,0,0 };
  35.  
  36.  
  37. void JCMouse::set_shape(image *im, int centerx, int centery)
  38. {
  39.   sp->change_visual(im,1);
  40.   cx=-centerx;
  41.   cy=-centery;
  42. }
  43.  
  44. JCMouse::JCMouse(image *Screen, palette *pal)
  45. {
  46.   image *im;
  47.   int br,dr,h;
  48.   filter f;
  49.   but=0;
  50.   cx=cy=0;
  51.   here=1;
  52.   sp=NULL;
  53.   if (here)                     // is it here?
  54.   {
  55.     screen=Screen;
  56.     br=pal->brightest(1);
  57.     dr=pal->darkest(1);
  58.     f.set(1,br);
  59.     f.set(2,dr);
  60.     im=new image(8,10,def_mouse);
  61.     f.apply(im);
  62.     sp=new sprite(Screen,im,100,100);
  63.   }
  64.   mx=Screen->width()/2;
  65.   my=Screen->height()/2;
  66.  
  67. }
  68.  
  69. void JCMouse::update(int newx, int newy, int new_but)
  70. {
  71.   int butn,xx,yy;
  72.   if (newx<0)
  73.   {
  74.     Window w1,w2;
  75.     int j;
  76.     unsigned int mask;
  77.     lx=mx; ly=my; lbut=but;
  78.     XQueryPointer(display,mainwin,&w1,&w2,&j,&j,&mx,&my,&mask);
  79.     but=((mask&Button1Mask)!=0)|
  80.          ((mask&Button2Mask)!=0)<<2|
  81.          ((mask&Button3Mask)!=0)<<1;
  82.   } else 
  83.   { mx=newx; my=newy; but=new_but; }
  84. }
  85.  
  86. void JCMouse::set_position(int new_mx, int new_my)
  87. {
  88.   mx=new_mx;
  89.   my=new_my;
  90.   XWarpPointer(display,mainwin,mainwin,0,0,0,0,new_mx,new_my);
  91. }
  92.  
  93. JCMouse::~JCMouse()
  94. {
  95.   if (sp) 
  96.   {
  97.     delete sp->visual;
  98.     delete sp;
  99.   }
  100. }
  101.  
  102.  
  103.  
  104.  
  105.